define generate_ll
	clang++ -Os -S -fobjc-arc -emit-llvm $(SRC_DIR)/$(1).cpp -o $(1).ll
	llvm-as $(1).ll -o $(1).bc
endef
SRC_DIR = ./src

main: main.bc base_util.bc exchange.bc call_and_return.bc point_heap.bc
	llvm-link main.bc base_util.bc exchange.bc call_and_return.bc point_heap.bc -o main_plase_analysis.bc
	llvm-link main.ll base_util.ll exchange.ll call_and_return.ll point_heap.ll -o main_plase_analysis.ll

main.bc: $(SRC_DIR)/main.cpp
	$(call generate_ll,main)

base_util.bc: $(SRC_DIR)/base_util.cpp
	$(call generate_ll,base_util)

exchange.bc: $(SRC_DIR)/exchange.cpp
	$(call generate_ll,exchange)

call_and_return.bc: $(SRC_DIR)/call_and_return.cpp
	$(call generate_ll,call_and_return)

point_heap.bc: $(SRC_DIR)/point_heap.cpp
	$(call generate_ll,point_heap)

all:main

# clang++ -Os -S -fobjc-arc -emit-llvm main.cpp -o main.bc
# lli main_plase_analysis.bc
